package com.aotain.jupiter.domain;

import org.apache.flink.api.common.functions.ReduceFunction;
import org.apache.flink.api.java.tuple.Tuple2;

import com.aotain.jupiter.common.URLStatTuple;

public class DomainReduce implements ReduceFunction<Tuple2<String, URLStatTuple>>{


	/**
	 * 
	 */
	private static final long serialVersionUID = 7657039731641641956L;

	@Override
	public Tuple2<String, URLStatTuple> reduce(
			Tuple2<String, URLStatTuple> value1,
			Tuple2<String, URLStatTuple> value2) throws Exception {
		// TODO Auto-generated method stub
		URLStatTuple info = new URLStatTuple();
		
		if(value1.f1 != null && value2.f1 != null) {
			info.setHTTPNum(value1.f1.getHTTPNum() + value2.f1.getHTTPNum());
		
		} else {
			System.out.println("reduce arg is null");
		}
		return new Tuple2<String, URLStatTuple> (value1.f0,info);
	}

}
